<template>
	<view class="content">
		<view class="title">评价星级</view>
		<uni-rate v-if="isTrue" :readonly="true" :size="20" :value="apply_star_num"></uni-rate>
		<view class="title">评价内容</view>
		<view class="cont">{{apply_text}}</view>
	</view>
</template>

<script>
	import uniRate from "@/components/uni-rate/uni-rate.vue"
	export default{
		components:{
			uniRate
		},
		data() {
			return {
				tid: '',
				apply_star_num: 1,
				apply_text: '',
				isTrue: false
			}
		},
		onLoad(e) {
			this.tid = e.tid;
			if(e.type == 2) {
				this.getRating();
			} else {
				this.getMyRating();
			}
		},
		methods:{
			getMyRating(){
				this.$zapi.apiPost('user/resources.lists/GetResApplyByApplyidDetail',{tid:this.tid}).then(res=>{
					if(res.data.code == 200) {
						var data = res.data.data;
						this.apply_star_num = data.apply_star_num;
						this.apply_text = data.apply_text;
						this.isTrue = true;
					}
				})
			},
			// 课包评价详情
			getRating() {
				this.$papi.apiPost('moblie/package/comment/info/'+this.tid, {
					unid: this.tid
				}).then(res => {
					if (res.data.code == 200) {
						var data = res.data.data;
						this.apply_star_num = data.level;
						this.apply_text = data.context;
						this.isTrue = true;
					} else {
						uni.showToast({
							title: res.data.message,
							icon: 'none'
						});
					}
				});
			}
		}
	}
</script>

<style>
	.content{
		padding: 40upx;
	}
	.title{
		color: #999999;
		font-size: 34upx;
		line-height: 1;
		margin-bottom: 30upx;
	}
	.uni-rate{
		margin-bottom: 50upx;
	}
	.cont{
		color: #333333;
		font-size: 34upx;
	}
</style>
